D r a w B o a r d ( ) ; 
 
 P l a n t B o m b s ( ) ; 
 
 S h o w B o m b s ( ) ; 
 
 F i l l e d C i r c l e ( ) ; 
 
 P r e s s S q u a r e ( ) ; 
 
 A d j a c e n t B o m b s ( ) ; 
 
 I s B o m b ( ) ; 
 
 P r e s s A d j a c e n t S q u a r e s ( ) ; 
 
 G a m e W o n ( ) ; 
 
 P l a c e F l a g ( ) ; 
 
 P l a c e Q u e s t i o n ( ) ; 
 
 S e l e c t M o d e ( ) ; 
 
 M o v e H i g h l i g h t ( ) ; 
 
 H i g h l i g h t ( ) ; 
 
 P r e P r e s s ( ) ; 
 
 P r i n t U n f l a g g e d B o m b s ( ) ; 
 
 I n t T o S t r i n g ( ) ; 
 
 D i g i t T o C h a r ( ) ; 
 
 m i n e f i e l d ; 
 
 b o m b s ; 
 
 u n f l a g g e d ; 
 
 c o l o r L i s t ; 
 
 n u m b e r L i s t ; 
 
 
 
 E X P O R T   M i n e s w e e p e r ( ) 
 
 / / M i n e s w e e p e r   v 1 . 4 . 4 
 
 / / 2 0 1 8 
 
 / / T o n y   G a l l o 
 
 / / t g a l l o @ t b a y t e l . c o m 
 
 / / h t t p : / / m y . t b a y t e l . n e t / t g a l l o / h p   p r i m e 
 
 
 
 B E G I N 
 
 
 
 l o c a l   t o u c h ; 
 
 l o c a l   d o n e ; 
 
 l o c a l   c h o i c e ; 
 
 l o c a l   i , j ,   i n d x ; 
 
 l o c a l   m o d e ,   m o d e t e m p ;   
 
 l o c a l   h i g h l i g h t i n d e x ; 
 
 l o c a l   k e y ; 
 
 l o c a l   r e s u l t ; 
 
 
 
 
 
 / / t i t l e   s c r e e n 
 
 R E C T _ P ( 0 , 0 , 3 1 9 , 2 3 9 , 0 , R G B ( 0 , 0 , 0 ) ) ; 
 
 T E X T O U T _ P ( " M I N E S W E E P E R " , 1 2 0 , 9 0 , 2 , R G B ( 2 5 5 , 0 , 0 ) ) ; 
 
 T E X T O U T _ P ( " v 1 . 4 . 4       2 0 1 8 " , 1 2 9 , 1 1 0 , 1 , R G B ( 2 5 5 , 0 , 0 ) ) ; 
 
 T E X T O U T _ P ( " b y   T o n y   G a l l o " , 1 2 8 , 1 3 0 , 1 , R G B ( 2 5 5 , 0 , 0 ) ) ; 
 
 
 
 w a i t ( 1 . 5 ) ; 
 
 
 
 
 
 c o l o r L i s t   : =   { R G B ( 1 , 0 , 2 5 4 ) , R G B ( 1 , 1 2 7 , 1 ) , R G B ( 2 5 4 , 0 , 0 ) , R G B ( 1 , 0 , 1 2 8 ) , R G B ( 1 2 9 , 1 , 2 ) , R G B ( 0 , 1 2 8 , 1 2 9 ) , R G B ( 0 , 0 , 0 ) , R G B ( 1 2 8 , 1 2 8 , 1 2 8 ) } ; 
 
 
 
 d o n e : =   0 ; 
 
 W H I L E   ( d o n e = = 0 )   D O 
 
 
 
 C H O O S E ( c h o i c e ,   " C h o o s e   D i f f i c u l t y   L e v e l " ,   " B e g i n n e r   -   1 0   m i n e s " ,   " I n t e r m e d i a t e   -   1 5   m i n e s " ,   " A d v a n c e d   -   2 0   m i n e s " ) ; 
 
 
 
 i f   c h o i c e   = =   0   t h e n 
 
 / / c l i c k e d   o u t s i d e   c h o o s e   b o x   -   d e f a u l t   t o   B e g i n n e r 
 
       c h o i c e : = 1 ; 
 
 e n d ; 
 
 
 
 b o m b s   : =   5   +   c h o i c e * 5 ; 
 
 
 
 / / c l e a r   s c r e e n 
 
 R E C T _ P ( 0 , 0 , 3 1 9 , 2 3 9 , 0 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 
 
 / / c r e d i t s 
 
 T E X T O U T _ P ( " M I N E S W E E P E R " , 1 0 , 5 , 2 , R G B ( 0 , 0 , 0 ) ) ; 
 
 T E X T O U T _ P ( " v 1 . 4 . 4       2 0 1 8 " , 1 0 0 , 6 , 1 , R G B ( 0 , 0 , 0 ) ) ; 
 
 T E X T O U T _ P ( " b y   T o n y   G a l l o " , 2 5 0 , 5 , 1 , R G B ( 0 , 0 , 0 ) ) ; 
 
 
 
 / / m o d e   m e n u 
 
 T E X T O U T _ P ( " M O D E : " , 1 0 , 5 0 , 2 , R G B ( 0 , 0 , 0 ) ) ; 
 
 
 
 T E X T O U T _ P ( " !" , 2 5 , 7 5 , 2 , R G B ( 0 , 0 , 0 ) ) ; 
 
 T E X T O U T _ P ( " p r e s s " , 1 5 , 9 0 , 1 , R G B ( 0 , 0 , 0 ) ) ; 
 
 
 
 P l a c e F l a g ( - 1 ,   0 ) ; 
 
 T E X T O U T _ P ( " f l a g " , 2 0 , 1 4 0 , 1 , R G B ( 0 , 0 , 0 ) ) ; 
 
 
 
 T E X T O U T _ P ( " ? " , 2 7 , 1 7 5 , 2 , R G B ( 0 , 0 , 0 ) ) ; 
 
 T E X T O U T _ P ( " u n k n o w n " , 8 , 1 8 7 , 1 , R G B ( 0 , 0 , 0 ) ) ; 
 
 
 
 
 
 / / p r e s s 
 
 L I N E _ P ( 1 0 , 7 0 , 4 5 , 7 0 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 1 0 , 1 0 5 , 4 5 , 1 0 5 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 1 0 , 7 0 , 1 0 , 1 0 5 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 4 5 , 7 0 , 4 5 , 1 0 5 , R G B ( 0 , 0 , 0 ) ) ; 
 
 m o d e   : =   0 ;     / / 0   -   p r e s s ,   1   -   f l a g ,   2   -   u n k n o w n 
 
 
 
 D r a w B o a r d ( ) ; 
 
 P l a n t B o m b s ( ) ; 
 
 u n f l a g g e d   : =   b o m b s ; 
 
 P r i n t U n f l a g g e d B o m b s ( u n f l a g g e d ) ; 
 
 
 
 h i g h l i g h t i n d e x   : =   - 1 ; 
 
 
 
 W H I L E   I S K E Y D O W N ( 4 ) < > 1   d o 
 
       w a i t ( . 1 ) ; 
 
       t o u c h : = m o u s e ( ) ; 
 
           k e y : = - 1 ; 
 
 
 
           k e y : = g e t k e y ; 
 
 
 
           i f   h i g h l i g h t i n d e x   > =   1   t h e n 
 
             H i g h l i g h t ( h i g h l i g h t i n d e x ,   1 ) ; 
 
           e n d ; 
 
 
 
 
 
           i f   k e y = = 2   o r   k e y = = 7   o r   k e y = = 8   o r   k e y = = 1 2   t h e n 
 
       h i g h l i g h t i n d e x   : =   M o v e H i g h l i g h t ( k e y ,   h i g h l i g h t i n d e x ) ; 
 
       c o n t i n u e ; 
 
           e n d ; 
 
 
 
           i f   k e y   = =   3 0   t h e n 
 
       / / p r e s s e d   b o a r d   w i t h   E N T E R 
 
             i f   h i g h l i g h t i n d e x   > =   1   t h e n 
 
             r e s u l t   : =   P r e P r e s s ( h i g h l i g h t i n d e x ,   m o d e ,   1 ) ; 
 
 
 
       
 
                   i f   r e s u l t   = =   " c o n t i n u e "   t h e n   c o n t i n u e ;   e n d ; 
 
                   i f   r e s u l t   = =   " b r e a k "   t h e n   b r e a k ;   e n d ; 
 
       e n d ; 
 
           e n d ; 
 
 
 
 
 
           i f   s i z e ( t o u c h ( 1 ) )   t h e n 
 
                     i f     t o u c h ( 1 , 5 ) = = 0   t h e n 
 
                             X : = B !R ( t o u c h ( 1 , 1 ) ) ; 
 
                             Y : = B !R ( t o u c h ( 1 , 2 ) ) ; 
 
 
 
       i f   1 0 < = X < = 4 5   a n d   7 0 < = Y < = 2 0 0   T H E N 
 
             m o d e t e m p   : =   S e l e c t M o d e ( X , Y ) ; 
 
             i f   0 < = m o d e t e m p < = 2   t h e n 
 
                   m o d e   : =   m o d e t e m p ; 
 
             e n d ; 
 
       e n d ;   
 
 
 
       i f   6 0 < = X < = 2 5 9   a n d   2 0 < = Y < = 2 1 9   T H E N 
 
       / / p r e s s e d   b o a r d   w i t h   f i n g e r 
 
 
 
                   
 
                               i : = i q u o ( ( X - 6 0 ) , 2 0 ) ; 
 
                               j : = i q u o ( ( Y - 2 0 ) , 2 0 ) ; 
 
                               i n d x   : =   1 0 * j   +   i   +   1 ; 
 
 
 
 
 
       r e s u l t   : =   P r e P r e s s ( i n d x ,   m o d e ,   0 ) ; 
 
       
 
       i f   r e s u l t   = =   " c o n t i n u e "   t h e n   c o n t i n u e ;   e n d ; 
 
       i f   r e s u l t   = =   " b r e a k "   t h e n   b r e a k ;   e n d ; 
 
 
 
           E N D ; 
 
 
 
             e n d ; 
 
       e n d ; 
 
 E N D ; 
 
 
 
 k e y : = - 1 ; 
 
 w h i l e   k e y   =   - 1   d o 
 
         w a i t ( . 1 ) ; 
 
       t o u c h : = m o u s e ( ) ; 
 
           k e y : = g e t k e y ; 
 
 e n d ; 
 
 
 
 C H O O S E ( c h o i c e ,   " P l a y   A g a i n ? " ,   " Y e s " ,   " N o " ) ; 
 
 i f   c h o i c e   < >   1   t h e n   d o n e : = 1 ;   e n d ; 
 
 E N D ; 
 
 
 
 E N D ; 
 
 
 
 P r e P r e s s ( i n d x ,   m o d e ,   h i g h l i g h t e d ) 
 
 b e g i n 
 
 l o c a l   r e s u l t ; 
 
 l o c a l   I , J ; 
 
 
 
 r e s u l t : = " " ; 
 
 
 
               i f   m o d e   = =   1   a n d   m i n e f i e l d ( i n d x )   >   8   t h e n 
 
                   P l a c e F l a g ( i n d x ,   h i g h l i g h t e d ) ; 
 
       P r i n t U n f l a g g e d B o m b s ( u n f l a g g e d ) ; 
 
                   r e s u l t   : =   " c o n t i n u e " ; 
 
       r e t u r n   r e s u l t ; 
 
               e n d ; 
 
 
 
               i f   m o d e   = =   2   a n d   m i n e f i e l d ( i n d x )   >   8   t h e n 
 
                   P l a c e Q u e s t i o n ( i n d x ,   h i g h l i g h t e d ) ; 
 
                   r e s u l t   : =   " c o n t i n u e " ;       
 
       r e t u r n   r e s u l t ; 
 
               e n d ; 
 
 
 
       i f   m i n e f i e l d ( i n d x )   = =   1 2   o r   m i n e f i e l d ( i n d x )   = =   1 4   t h e n 
 
       / / f l a g g e d   -   c a n n o t   p r e s s 
 
                   r e s u l t   : =   " c o n t i n u e " ;       
 
       r e t u r n   r e s u l t ; 
 
       e n d ; 
 
 
 
               i f   m i n e f i e l d ( i n d x )   = =   1 1   o r   m i n e f i e l d ( i n d x )   = =   1 5   t h e n 
 
                                     S h o w B o m b s ( 0 ) ; 
 
 
 
             I   : =   i r e m ( i n d x - 1 , 1 0 ) ; 
 
             J   : =   i q u o ( i n d x - 1 , 1 0 ) ; 
 
 
 
 
 
             R E C T _ P ( 6 0 + 2 0 * I , 2 0 + 2 0 * J , 8 0 + 2 0 * I , 4 0 + 2 0 * J , 0 , R G B ( 1 9 2 , 1 9 2 , 1 9 2 ) ) ;   
 
                         F i l l e d C i r c l e ( 7 0   +   2 0 * i r e m ( i n d x - 1 , 1 0 ) , 3 0   +   2 0 * i q u o ( i n d x - 1 , 1 0 ) , 4 , R G B ( 2 5 5 , 0 , 0 ) ) ; 
 
                     T E X T O U T _ P ( " Y O U " , 2 7 8 , 3 5 , 2 , R G B ( 2 5 5 , 0 , 0 ) ) ; 
 
                     T E X T O U T _ P ( " L O S E ! " , 2 7 5 , 5 0 , 2 , R G B ( 2 5 5 , 0 , 0 ) ) ; 
 
       T E X T O U T _ P ( " P r e s s   a n y " , 2 6 5 , 8 0 , 2 , R G B ( 0 , 0 , 0 ) ) ; 
 
       T E X T O U T _ P ( " k e y . " , 2 8 0 , 9 5 , 2 , R G B ( 0 , 0 , 0 ) ) ; 
 
 
 
                               r e s u l t   : =   " b r e a k " ; 
 
       r e t u r n   r e s u l t ; 
 
             e l s e 
 
                         P r e s s S q u a r e ( i n d x ) ; 
 
                         i f   G a m e W o n ( )   = =   1   t h e n 
 
                                     S h o w B o m b s ( 1 ) ; 
 
                     T E X T O U T _ P ( " Y O U " , 2 7 8 , 3 5 , 2 , R G B ( 0 , 0 , 0 ) ) ; 
 
                     T E X T O U T _ P ( " W I N ! " , 2 7 7 , 5 0 , 2 , R G B ( 0 , 0 , 0 ) ) ; 
 
       T E X T O U T _ P ( " P r e s s   a n y " , 2 6 5 , 8 0 , 2 , R G B ( 0 , 0 , 0 ) ) ; 
 
       T E X T O U T _ P ( " k e y . " , 2 8 0 , 9 5 , 2 , R G B ( 0 , 0 , 0 ) ) ; 
 
 
 
                                           r e s u l t   : =   " b r e a k " ; 
 
             r e t u r n   r e s u l t ; 
 
                         e n d ; 
 
             e n d ; 
 
 
 
 r e t u r n   r e s u l t ; 
 
 e n d ; 
 
 
 
 
 
 
 
 P r i n t U n f l a g g e d B o m b s ( n u m b e r ) 
 
 b e g i n 
 
 R E C T _ P ( 2 8 0 , 1 7 5 , 3 0 5 , 1 9 5 , 0 , R G B ( 0 , 0 , 0 ) ) ; 
 
 T E X T O U T _ P ( I n t T o S t r i n g ( n u m b e r ) , 2 8 5 , 1 8 0 , 2 , R G B ( 2 5 5 , 0 , 0 ) ) ; 
 
 e n d ; 
 
 
 
 M o v e H i g h l i g h t ( k e y ,   h i g h l i g h t i n d e x ) 
 
 b e g i n 
 
 
 
       i f   h i g h l i g h t i n d e x   = =   -   1   t h e n 
 
             h i g h l i g h t i n d e x   : =   1 ; 
 
             H i g h l i g h t ( h i g h l i g h t i n d e x ,   1 ) ; 
 
             r e t u r n   1 ; 
 
       e n d ; 
 
 
 
       H i g h l i g h t ( h i g h l i g h t i n d e x ,   0 ) ; 
 
       
 
       C A S E 
 
             i f   k e y   = =   2   t h e n 
 
                   i f   1 < =   h i g h l i g h t i n d e x   < =   1 0   t h e n 
 
                         h i g h l i g h t i n d e x   : =   h i g h l i g h t i n d e x   +   9 0 ; 
 
                   e l s e 
 
                         h i g h l i g h t i n d e x   : =   h i g h l i g h t i n d e x   -   1 0 ; 
 
                   e n d ; 
 
             e n d ; 
 
 
 
             i f   k e y   = =   7   t h e n 
 
                   i f   i r e m ( h i g h l i g h t i n d e x , 1 0 )   = =   1   t h e n 
 
                         h i g h l i g h t i n d e x   : =   h i g h l i g h t i n d e x   +   9 ; 
 
                   e l s e 
 
                         h i g h l i g h t i n d e x   : =   h i g h l i g h t i n d e x   -   1 ; 
 
                   e n d ; 
 
             e n d ; 
 
 
 
             i f   k e y   = =   8   t h e n 
 
                   i f   i r e m ( h i g h l i g h t i n d e x , 1 0 )   = =   0   t h e n 
 
                         h i g h l i g h t i n d e x   : =   h i g h l i g h t i n d e x   -   9 ; 
 
                   e l s e 
 
                         h i g h l i g h t i n d e x   : =   h i g h l i g h t i n d e x   +   1 ; 
 
                   e n d ; 
 
             e n d ; 
 
 
 
             i f   k e y   = =   1 2   t h e n 
 
                   i f   9 1 < =   h i g h l i g h t i n d e x   < =   1 0 0   t h e n 
 
                         h i g h l i g h t i n d e x   : =   h i g h l i g h t i n d e x   -   9 0 ; 
 
                   e l s e 
 
                         h i g h l i g h t i n d e x   : =   h i g h l i g h t i n d e x   +   1 0 ; 
 
                   e n d ; 
 
             e n d ; 
 
 
 
       E N D ; 
 
 
 
       H i g h l i g h t ( h i g h l i g h t i n d e x ,   1 ) ; 
 
 
 
       r e t u r n   h i g h l i g h t i n d e x ; 
 
 e n d ; 
 
 
 
 
 
 H i g h l i g h t ( i n d x ,   m o d e ) 
 
 b e g i n 
 
 / / m o d e   0   -   u n h i g h l i g h t 
 
 / / m o d e   1   -   h i g h l i g h t 
 
 l o c a l   c o l o r ; 
 
 l o c a l   I , J ; 
 
 
 
             I   : =   i r e m ( i n d x - 1 , 1 0 ) ; 
 
             J   : =   i q u o ( i n d x - 1 , 1 0 ) ; 
 
 
 
       i f   m o d e   = =   0   t h e n   c o l o r : = R G B ( 0 , 0 , 0 ) ;   e n d ; 
 
       i f   m o d e   = =   1   t h e n   c o l o r : = R G B ( 2 5 5 , 2 4 4 , 4 3 ) ;   e n d ; 
 
 
 
       L I N E _ P ( 6 0 + I * 2 0 , 2 0 + J * 2 0 , 6 0 + I * 2 0 , 4 0 + J * 2 0 , c o l o r ) ; 
 
       L I N E _ P ( 8 0 + I * 2 0 , 2 0 + J * 2 0 , 8 0 + I * 2 0 , 4 0 + J * 2 0 , c o l o r ) ; 
 
 
 
       L I N E _ P ( 6 0 + I * 2 0 , 2 0 + J * 2 0 , 8 0 + I * 2 0 , 2 0 + J * 2 0 , c o l o r ) ; 
 
       L I N E _ P ( 6 0 + I * 2 0 , 4 0 + J * 2 0 , 8 0 + I * 2 0 , 4 0 + J * 2 0 , c o l o r ) ; 
 
 e n d ; 
 
 
 
 I s B o m b ( i n d x ) 
 
 b e g i n 
 
       i f   m i n e f i e l d ( i n d x )   = =   1 1   o r   m i n e f i e l d ( i n d x )   = =   1 4   o r   m i n e f i e l d ( i n d x )   = =   1 5   t h e n 
 
             r e t u r n   1 ; 
 
       e l s e 
 
             r e t u r n   0 ; 
 
       e n d ; 
 
 e n d ; 
 
 
 
 
 
 
 
 A d j a c e n t B o m b s ( i n d x ) 
 
 b e g i n 
 
       l o c a l   c o u n t ; 
 
       c o u n t : = 0 ; 
 
 
 
       C A S E 
 
       / / t o p   l e f t   c o r n e r 
 
       i f   i n d x   = =   1   t h e n 
 
             c o u n t : =   I s B o m b ( i n d x + 1 )       +   I s B o m b ( i n d x + 1 0 )   +   I s B o m b ( i n d x + 1 1 ) ; 
 
       e n d ; 
 
 
 
       / / t o p   r o w 
 
       i f   2 < =   i n d x   < =   9   t h e n 
 
             c o u n t : =   I s B o m b ( i n d x - 1 )   +   I s B o m b ( i n d x + 1 ) 
 
               +   I s B o m b ( i n d x + 9 )   +   I s B o m b ( i n d x + 1 0 )   +   I s B o m b ( i n d x + 1 1 ) ; 
 
       e n d ; 
 
 
 
       / / t o p   r i g h t   c o r n e r 
 
       i f   i n d x   = =   1 0   t h e n 
 
             c o u n t : =   I s B o m b ( i n d x - 1 )       +   I s B o m b ( i n d x + 9 )   +   I s B o m b ( i n d x + 1 0 ) ; 
 
       e n d ; 
 
 
 
       / / b o t t o m   l e f t   c o r n e r 
 
       i f   i n d x   = =   9 1   t h e n 
 
             c o u n t : =   I s B o m b ( i n d x - 1 0 )       +   I s B o m b ( i n d x - 9 )   +   I s B o m b ( i n d x + 1 ) ; 
 
       e n d ; 
 
 
 
       / / b o t t o m   r o w 
 
       i f   9 2 < =   i n d x   < =   9 9   t h e n 
 
             c o u n t : =   I s B o m b ( i n d x - 1 1 )   +   I s B o m b ( i n d x - 1 0 )   +   I s B o m b ( i n d x - 9 ) 
 
               +   I s B o m b ( i n d x - 1 )   +   I s B o m b ( i n d x + 1 ) ; 
 
       e n d ; 
 
 
 
       / / b o t t o m   r i g h t   c o r n e r 
 
       i f   i n d x   = =   1 0 0   t h e n 
 
             c o u n t : =   I s B o m b ( i n d x - 1 1 )       +   I s B o m b ( i n d x - 1 0 )   +   I s B o m b ( i n d x - 1 ) ; 
 
         e n d ; 
 
 
 
       / / f a r m o s t   l e f t   c o l u m n 
 
       i f   i r e m ( i n d x , 1 0 )   = =   1   t h e n 
 
             c o u n t : =   I s B o m b ( i n d x - 1 0 )   +   I s B o m b ( i n d x - 9 ) 
 
               +   I s B o m b ( i n d x + 1 )   +   I s B o m b ( i n d x + 1 0 )   +   I s B o m b ( i n d x + 1 1 ) ;             
 
       e n d ; 
 
 
 
       / / f a r m o s t   r i g h t   c o l u m n 
 
       i f   i r e m ( i n d x , 1 0 )   = =   0   t h e n 
 
             c o u n t : =   I s B o m b ( i n d x - 1 1 )   +   I s B o m b ( i n d x - 1 0 ) 
 
               +   I s B o m b ( i n d x - 1 )   +   I s B o m b ( i n d x + 9 )   +   I s B o m b ( i n d x + 1 0 ) ;             
 
       e n d ; 
 
 
 
       / / e v e r y w h e r e   e l s e   ( i n   t h e   m i d d l e ) 
 
             c o u n t : =   I s B o m b ( i n d x - 1 1 )   +   I s B o m b ( i n d x - 1 0 )   +   I s B o m b ( i n d x - 9 ) 
 
               +   I s B o m b ( i n d x - 1 )   +   I s B o m b ( i n d x + 1 ) 
 
       +   I s B o m b ( i n d x + 9 )   +   I s B o m b ( i n d x + 1 0 )   +   I s B o m b ( i n d x + 1 1 ) ; 
 
 
 
       E N D ; 
 
 
 
       r e t u r n   c o u n t ; 
 
 e n d ; 
 
 
 
 
 
 P r e s s S q u a r e ( i n d x ) 
 
 b e g i n 
 
 l o c a l   b o m b c o u n t ; 
 
 l o c a l   I ,   J ;   
 
 
 
       I   : =   i r e m ( i n d x - 1 , 1 0 ) ; 
 
       J   : =   i q u o ( i n d x - 1 , 1 0 ) ; 
 
 
 
 
 
       R E C T _ P ( 6 0 + 2 0 * I , 2 0 + 2 0 * J , 8 0 + 2 0 * I , 4 0 + 2 0 * J , 0 , R G B ( 1 9 2 , 1 9 2 , 1 9 2 ) ) ;   
 
 
 
 
 
       b o m b c o u n t : = A d j a c e n t B o m b s ( i n d x ) ; 
 
       m i n e f i e l d ( i n d x )   : =   b o m b c o u n t ; 
 
 
 
       i f   b o m b c o u n t   < >   0   t h e n 
 
               T E X T O U T _ P ( D i g i t T o C h a r ( b o m b c o u n t ) , 6 7 + 2 0 * I , 2 5 + 2 0 * J , 2 , c o l o r L i s t ( b o m b c o u n t ) ) ; 
 
       e l s e 
 
             P r e s s A d j a c e n t S q u a r e s ( i n d x ) ; 
 
       e n d ; 
 
 e n d ; 
 
 
 
 
 
 P r e s s A d j a c e n t S q u a r e ( i n d x ) 
 
 b e g i n 
 
       i f   m i n e f i e l d ( i n d x )   =   1 0   o r   m i n e f i e l d ( i n d x )   =   1 3   t h e n 
 
             P r e s s S q u a r e ( i n d x ) ; 
 
       e n d ; 
 
 e n d ; 
 
 
 
 P r e s s A d j a c e n t S q u a r e s ( i n d x ) 
 
 b e g i n 
 
 
 
             C A S E 
 
       / / t o p   l e f t   c o r n e r 
 
       i f   i n d x   = =   1   t h e n 
 
               P r e s s A d j a c e n t S q u a r e ( i n d x + 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 0 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 1 ) ; 
 
       e n d ; 
 
 
 
       / / t o p   r o w 
 
       i f   2 < =   i n d x   < =   9   t h e n 
 
                 P r e s s A d j a c e n t S q u a r e ( i n d x - 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 ) ; 
 
           P r e s s A d j a c e n t S q u a r e ( i n d x + 9 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 0 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 1 ) ; 
 
       e n d ; 
 
 
 
       / / t o p   r i g h t   c o r n e r 
 
       i f   i n d x   = =   1 0   t h e n 
 
                   P r e s s A d j a c e n t S q u a r e ( i n d x - 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 9 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 0 ) ; 
 
       e n d ; 
 
 
 
       / / b o t t o m   l e f t   c o r n e r 
 
       i f   i n d x   = =   9 1   t h e n 
 
                   P r e s s A d j a c e n t S q u a r e ( i n d x - 1 0 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 9 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 ) ; 
 
       e n d ; 
 
 
 
       / / b o t t o m   r o w 
 
       i f   9 2 < =   i n d x   < =   9 9   t h e n 
 
                   P r e s s A d j a c e n t S q u a r e ( i n d x - 1 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 1 0 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 9 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 ) ; 
 
       e n d ; 
 
 
 
       / / b o t t o m   r i g h t   c o r n e r 
 
       i f   i n d x   = =   1 0 0   t h e n 
 
                   P r e s s A d j a c e n t S q u a r e ( i n d x - 1 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 1 0 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 1 ) ; 
 
         e n d ; 
 
 
 
       / / f a r m o s t   l e f t   c o l u m n 
 
       i f   i r e m ( i n d x , 1 0 )   = =   1   t h e n 
 
                 P r e s s A d j a c e n t S q u a r e ( i n d x - 1 0 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 9 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 0 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 1 ) ;             
 
       e n d ; 
 
 
 
       / / f a r m o s t   r i g h t   c o l u m n 
 
       i f   i r e m ( i n d x , 1 0 )   = =   0   t h e n 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 1 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 1 0 ) ; 
 
                     P r e s s A d j a c e n t S q u a r e ( i n d x - 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 9 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 0 ) ;             
 
       e n d ; 
 
 
 
       / / e v e r y w h e r e   e l s e   ( i n   t h e   m i d d l e ) 
 
                   P r e s s A d j a c e n t S q u a r e ( i n d x - 1 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 1 0 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 9 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x - 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 9 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 0 ) ; 
 
       P r e s s A d j a c e n t S q u a r e ( i n d x + 1 1 ) ; 
 
 
 
       E N D ; 
 
 
 
 e n d ; 
 
 
 
 
 
 
 
 D r a w B o a r d ( ) 
 
 b e g i n 
 
 l o c a l   I ; 
 
 
 
 
 
 R E C T _ P ( 6 0 , 2 0 , 2 6 0 , 2 2 0 , 0 , R G B ( 6 5 , 1 0 5 , 2 2 5 ) ) ; 
 
 
 
 F O R   I   F R O M   1   t o   9   D O 
 
   L I N E _ P ( 6 0 + 2 0 * I , 2 0 , 6 0 + 2 0 * I , 2 2 0 , R G B ( 0 , 0 , 0 ) ) ;   
 
   L I N E _ P ( 6 0 , 2 0 + 2 0 * I , 2 6 0 , 2 0 + 2 0 * I , R G B ( 0 , 0 , 0 ) ) ;   
 
   
 
 E N D ; 
 
 
 
 e n d ; 
 
 
 
 
 
 P l a n t B o m b s ( ) 
 
 b e g i n 
 
 l o c a l   i n d x ,   c o u n t ; 
 
 c o u n t : = 0 ; 
 
 
 
 / / m i n e f i e l d   v a l u e s : 
 
 / / 0 - 8   -   #   o f   a d j a c e n t   b o m b s 
 
 / / 1 0   -   n o t h i n g 
 
 / / 1 1   -   b o m b 
 
 / / 1 2   -   f l a g g e d   n o t h i n g 
 
 / / 1 3   -   q u e s t i o n   n o t h i n g 
 
 / / 1 4   -   f l a g g e d   b o m b 
 
 / / 1 5   -   q u e s t i o n   b o m b 
 
 
 
 m i n e f i e l d : = m a k e l i s t ( 1 0 , A , 1 , 1 0 0 , 1 ) ; 
 
 
 
 W H I L E   ( c o u n t < b o m b s )   D O 
 
       i n d x   : =   R A N D I N T ( 1 , 1 0 0 ) ; 
 
       i f   m i n e f i e l d ( i n d x )   = =   1 0   t h e n 
 
             m i n e f i e l d ( i n d x )   : =   1 1 ; 
 
             c o u n t   : =   c o u n t   +   1 ;       
 
       e n d ; 
 
 E N D ; 
 
 
 
 r e t u r n   m i n e f i e l d ; 
 
 
 
 
 
 e n d ; 
 
 
 
 
 
 F i l l e d C i r c l e ( X , Y , R a d i u s , C o l o r ) 
 
 b e g i n 
 
 l o c a l   I ; 
 
 
 
         F O R   I   F R O M   0   T O   R a d i u s   D O 
 
         A R C _ P ( X , Y , I , C o l o r ) ; 
 
         E N D ; 
 
 e n d ; 
 
 
 
 S h o w B o m b s ( w i n ) 
 
 b e g i n 
 
 l o c a l   i n d x ; 
 
 l o c a l   I ,   J ;   
 
 l o c a l   c o l o r ; 
 
 
 
 i f   w i n   = =   1   t h e n 
 
       c o l o r   : =   R G B ( 6 5 , 1 0 5 , 2 2 5 ) ; 
 
 e l s e 
 
       c o l o r   : =   R G B ( 1 9 2 , 1 9 2 , 1 9 2 ) ; 
 
 e n d ; 
 
             I   : =   i r e m ( i n d x - 1 , 1 0 ) ; 
 
             J   : =   i q u o ( i n d x - 1 , 1 0 ) ; 
 
 
 
         F O R   i n d x   F R O M   1   T O   1 0 0   D O 
 
               
 
             I   : =   i r e m ( i n d x - 1 , 1 0 ) ; 
 
             J   : =   i q u o ( i n d x - 1 , 1 0 ) ; 
 
             i f   m i n e f i e l d ( i n d x )   = =   1 1   o r   m i n e f i e l d ( i n d x )   = =   1 4   o r   m i n e f i e l d ( i n d x )   = =   1 5   t h e n 
 
             R E C T _ P ( 6 0 + 2 0 * I , 2 0 + 2 0 * J , 8 0 + 2 0 * I , 4 0 + 2 0 * J , 0 , c o l o r ) ;   
 
                   F i l l e d C i r c l e ( 7 0   +   2 0 * I , 3 0   +   2 0 * J , 4 , R G B ( 0 , 0 , 0 ) ) ; 
 
             e n d ; 
 
 
 
             i f   m i n e f i e l d ( i n d x )   = =   1 2   t h e n 
 
       / / m i s f l a g g e d 
 
             R E C T _ P ( 6 0 + 2 0 * I , 2 0 + 2 0 * J , 8 0 + 2 0 * I , 4 0 + 2 0 * J , 0 , c o l o r ) ;   
 
                   F i l l e d C i r c l e ( 7 0   +   2 0 * I , 3 0   +   2 0 * J , 4 , R G B ( 0 , 0 , 0 ) ) ; 
 
         L I N E _ P ( 6 0 + 2 0 * I , 2 0 + 2 0 * J , 8 0 + 2 0 * I , 4 0 + 2 0 * J , R G B ( 2 5 5 , 0 , 0 ) ) ; 
 
         L I N E _ P ( 8 0 + 2 0 * I , 2 0 + 2 0 * J , 6 0 + 2 0 * I , 4 0 + 2 0 * J , R G B ( 2 5 5 , 0 , 0 ) ) ; 
 
             e n d ; 
 
       
 
         E N D ; 
 
 e n d ; 
 
 
 
 G a m e W o n ( ) 
 
 b e g i n 
 
 l o c a l   i n d x ; 
 
 l o c a l   c o u n t ; 
 
 
 
 c o u n t   : =   0 ; 
 
 
 
         F O R   i n d x   F R O M   1   T O   1 0 0   D O 
 
               i f   m i n e f i e l d ( i n d x )   < =   8   t h e n 
 
                   c o u n t : = c o u n t   + 1 ; 
 
               e n d ; 
 
         E N D ; 
 
 
 
       i f   c o u n t   = =   1 0 0   -   b o m b s   t h e n 
 
       r e t u r n   1 ; 
 
       e l s e 
 
       r e t u r n   0 ; 
 
       e n d ; 
 
 e n d ; 
 
 
 
 
 
 P l a c e F l a g ( i n d x ,   h i g h l i g h t e d ) 
 
 b e g i n 
 
 l o c a l   I ,   J ;   
 
 l o c a l   b o r d e r ; 
 
 
 
 i f   h i g h l i g h t e d   = =   0   t h e n 
 
       b o r d e r : = R G B ( 0 , 0 , 0 ) ; 
 
 e l s e 
 
     b o r d e r : = R G B ( 2 5 5 , 2 4 4 , 4 3 ) ; 
 
 e n d ; 
 
 
 
       i f   i n d x   > =   1   t h e n 
 
             I   : =   i r e m ( i n d x - 1 , 1 0 ) ; 
 
             J   : =   i q u o ( i n d x - 1 , 1 0 ) ; 
 
                             R E C T _ P ( 6 0 + 2 0 * I , 2 0 + 2 0 * J , 8 0 + 2 0 * I , 4 0 + 2 0 * J , b o r d e r , R G B ( 6 5 , 1 0 5 , 2 2 5 ) ) ;   
 
       e l s e   
 
       / / m e n u 
 
             I   : =   - 2 ; 
 
             J   : =   5 ; 
 
       e n d ; 
 
 
 
       i f   i n d x   > =   1   t h e n 
 
       i f   m i n e f i e l d ( i n d x )   = =   1 2   t h e n 
 
             m i n e f i e l d ( i n d x )   : =   1 0 ;   
 
             u n f l a g g e d   : =   u n f l a g g e d   +   1 ; 
 
             r e t u r n ; 
 
       e n d ; 
 
       i f   m i n e f i e l d ( i n d x )   = =   1 4   t h e n 
 
             m i n e f i e l d ( i n d x )   : =   1 1 ;   
 
             u n f l a g g e d   : =   u n f l a g g e d   +   1 ; 
 
             r e t u r n ; 
 
       e n d ; 
 
       i f   m i n e f i e l d ( i n d x )   = =   1 0   o r   m i n e f i e l d ( i n d x )   = =   1 3   t h e n 
 
             m i n e f i e l d ( i n d x )   : =   1 2 ;   
 
             u n f l a g g e d   : =   u n f l a g g e d   -   1 ; 
 
       e n d ; 
 
       i f   m i n e f i e l d ( i n d x )   = =   1 1   o r   m i n e f i e l d ( i n d x )   = =   1 5   t h e n 
 
             m i n e f i e l d ( i n d x )   : =   1 4 ;   
 
             u n f l a g g e d   : =   u n f l a g g e d   -   1 ; 
 
       e n d ; 
 
     e n d ; 
 
       
 
             R E C T _ P ( 6 0 + 2 0 * I + 4 , 2 0 + 2 0 * J + 5 , 8 0 + 2 0 * I - 7 , 4 0 + 2 0 * J - 1 0 , 0 , R G B ( 2 5 5 , 0 , 0 ) ) ;   
 
             L I N E _ P ( 8 0 + 2 0 * I - 7 , 4 0 + 2 0 * J - 1 0 , 8 0 + 2 0 * I - 7 , 4 0 + 2 0 * J - 5 , R G B ( 0 , 0 , 0 ) ) ;   
 
             L I N E _ P ( 6 0 + 2 0 * I + 1 0 , 4 0 + 2 0 * J - 5 , 8 0 + 2 0 * I - 5 , 4 0 + 2 0 * J - 5 , R G B ( 0 , 0 , 0 ) ) ;   
 
       
 
 e n d ; 
 
 
 
 P l a c e Q u e s t i o n ( i n d x ,   h i g h l i g h t e d ) 
 
 b e g i n 
 
 l o c a l   I ,   J ;   
 
 l o c a l   b o r d e r ; 
 
 
 
 i f   h i g h l i g h t e d   = =   0   t h e n 
 
       b o r d e r : = R G B ( 0 , 0 , 0 ) ; 
 
 e l s e 
 
       b o r d e r : = R G B ( 2 5 5 , 2 4 4 , 4 3 ) ; 
 
 e n d ; 
 
 
 
       I   : =   i r e m ( i n d x - 1 , 1 0 ) ; 
 
       J   : =   i q u o ( i n d x - 1 , 1 0 ) ; 
 
 
 
       R E C T _ P ( 6 0 + 2 0 * I , 2 0 + 2 0 * J , 8 0 + 2 0 * I , 4 0 + 2 0 * J , b o r d e r , R G B ( 6 5 , 1 0 5 , 2 2 5 ) ) ;   
 
       i f   m i n e f i e l d ( i n d x )   = =   1 3   t h e n 
 
             m i n e f i e l d ( i n d x )   : =   1 0 ;   
 
             r e t u r n ; 
 
       e n d ; 
 
       i f   m i n e f i e l d ( i n d x )   = =   1 5   t h e n 
 
             m i n e f i e l d ( i n d x )   : =   1 1 ;   
 
             r e t u r n ; 
 
       e n d ; 
 
       
 
       T E X T O U T _ P ( " ? " , 6 0 + 2 0 * I + 8 , 2 0 + 2 0 * J + 5 , 2 , R G B ( 0 , 0 , 0 ) ) ; 
 
 
 
       i f   m i n e f i e l d ( i n d x )   = =   1 0   o r   m i n e f i e l d ( i n d x )   = =   1 2   t h e n 
 
             m i n e f i e l d ( i n d x )   : =   1 3 ;   
 
       e n d ; 
 
       i f   m i n e f i e l d ( i n d x )   = =   1 1   o r   m i n e f i e l d ( i n d x )   = =   1 4   t h e n 
 
             m i n e f i e l d ( i n d x )   : =   1 5 ;   
 
       e n d ; 
 
       
 
 e n d ; 
 
 
 
 
 
 S e l e c t M o d e ( x , y ) 
 
 b e g i n 
 
 l o c a l   m o d e ; 
 
 
 
 m o d e : = - 1 ; 
 
 
 
 c a s e 
 
       i f   7 0 < = Y < = 1 0 5   t h e n   m o d e : = 0 ;   e n d ; 
 
       i f   1 2 0 < = Y < = 1 5 5   t h e n   m o d e : = 1 ;   e n d ; 
 
       i f   1 7 0 < = Y < = 2 0 0   t h e n   m o d e : = 2 ;   e n d ;       
 
 e n d ; 
 
 
 
 i f   m o d e   = =   - 1   t h e n 
 
       r e t u r n   m o d e ; 
 
 e n d ; 
 
 
 
 / / c l e a r   b o x e s 
 
 
 
 / / p r e s s 
 
 L I N E _ P ( 1 0 , 7 0 , 4 5 , 7 0 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 L I N E _ P ( 1 0 , 1 0 5 , 4 5 , 1 0 5 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 L I N E _ P ( 1 0 , 7 0 , 1 0 , 1 0 5 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 L I N E _ P ( 4 5 , 7 0 , 4 5 , 1 0 5 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 
 
 / / f l a g 
 
 L I N E _ P ( 1 0 , 1 2 0 , 4 5 , 1 2 0 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 L I N E _ P ( 1 0 , 1 5 5 , 4 5 , 1 5 5 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 L I N E _ P ( 1 0 , 1 2 0 , 1 0 , 1 5 5 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 L I N E _ P ( 4 5 , 1 2 0 , 4 5 , 1 5 5 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 
 
 / / u n k n o w n 
 
 L I N E _ P ( 4 , 1 7 0 , 5 1 , 1 7 0 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 L I N E _ P ( 4 , 2 0 0 , 5 1 , 2 0 0 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 L I N E _ P ( 4 , 1 7 0 , 4 , 2 0 0 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 L I N E _ P ( 5 1 , 1 7 0 , 5 1 , 2 0 0 , R G B ( 2 5 5 , 2 5 5 , 2 5 5 ) ) ; 
 
 
 
 c a s e 
 
       i f   m o d e   = =   0   t h e n 
 
 / / p r e s s 
 
 L I N E _ P ( 1 0 , 7 0 , 4 5 , 7 0 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 1 0 , 1 0 5 , 4 5 , 1 0 5 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 1 0 , 7 0 , 1 0 , 1 0 5 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 4 5 , 7 0 , 4 5 , 1 0 5 , R G B ( 0 , 0 , 0 ) ) ; 
 
       e n d ; 
 
 
 
       i f   m o d e   = =   1   t h e n 
 
 / / f l a g 
 
 L I N E _ P ( 1 0 , 1 2 0 , 4 5 , 1 2 0 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 1 0 , 1 5 5 , 4 5 , 1 5 5 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 1 0 , 1 2 0 , 1 0 , 1 5 5 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 4 5 , 1 2 0 , 4 5 , 1 5 5 , R G B ( 0 , 0 , 0 ) ) ; 
 
       e n d ; 
 
 
 
       i f   m o d e   = =   2   t h e n 
 
 / / u n k n o w n 
 
 L I N E _ P ( 4 , 1 7 0 , 5 1 , 1 7 0 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 4 , 2 0 0 , 5 1 , 2 0 0 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 4 , 1 7 0 , 4 , 2 0 0 , R G B ( 0 , 0 , 0 ) ) ; 
 
 L I N E _ P ( 5 1 , 1 7 0 , 5 1 , 2 0 0 , R G B ( 0 , 0 , 0 ) ) ; 
 
       e n d ; 
 
 e n d ; 
 
 
 
 r e t u r n   m o d e ; 
 
 e n d ; 
 
 
 
 I n t T o S t r i n g ( i n t e g e r ) 
 
 b e g i n 
 
 l o c a l   r e m ; 
 
 l o c a l   s t r i n g   =   " " ; 
 
 l o c a l   n e g a t i v e   =   0 ; 
 
 
 
 
 
 i f   i n t e g e r   = =   0   t h e n 
 
       r e t u r n   " 0 " ; 
 
 e n d ; 
 
 
 
 i f   i n t e g e r   <   0   t h e n 
 
       n e g a t i v e   : =   1 ; 
 
     i n t e g e r   : =   i n t e g e r   *   ( - 1 ) ; 
 
 e n d ; 
 
 
 
 w h i l e   i n t e g e r   >   0   d o 
 
     r e m   : =   i r e m ( i n t e g e r , 1 0 ) ; 
 
     s t r i n g   : =   D i g i t T o C h a r ( r e m )   +   s t r i n g   ; 
 
     i n t e g e r   : =   ( i n t e g e r   -   r e m ) / 1 0 ; 
 
 e n d ; 
 
 
 
 i f   n e g a t i v e   = =   1   t h e n 
 
     s t r i n g : =   " - "   +   s t r i n g ; 
 
 e n d ; 
 
 r e t u r n   s t r i n g ; 
 
 
 
 e n d ; 
 
 
 
 D i g i t T o C h a r ( d i g i t ) 
 
 b e g i n 
 
 
 
 i f   d i g i t   = =   0   t h e n 
 
     r e t u r n   " 0 " ; 
 
 e n d ; 
 
 
 
 i f   d i g i t   = =   1   t h e n 
 
     r e t u r n   " 1 " ; 
 
 e n d ; 
 
 
 
 i f   d i g i t   = =   2   t h e n 
 
     r e t u r n   " 2 " ; 
 
 e n d ; 
 
 
 
 i f   d i g i t   = =   3   t h e n 
 
     r e t u r n   " 3 " ; 
 
 e n d ; 
 
 
 
 i f   d i g i t   = =   4   t h e n 
 
     r e t u r n   " 4 " ; 
 
 e n d ; 
 
 
 
 i f   d i g i t   = =   5   t h e n 
 
     r e t u r n   " 5 " ; 
 
 e n d ; 
 
 
 
 i f   d i g i t   = =   6   t h e n 
 
     r e t u r n   " 6 " ; 
 
 e n d ; 
 
 
 
 i f   d i g i t   = =   7   t h e n 
 
     r e t u r n   " 7 " ; 
 
 e n d ; 
 
 
 
 i f   d i g i t   = =   8   t h e n 
 
     r e t u r n   " 8 " ; 
 
 e n d ; 
 
 
 
 i f   d i g i t   = =   9   t h e n 
 
     r e t u r n   " 9 " ; 
 
 e n d ; 
 
 
 
 e n d ; 